<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        *{
            padding: 0;
            margin: 0;
        }
        div{
            width: 200px;
            margin: auto;
        }
        input{
            outline: none;
            display: block;
            width: 180px;
            border: 1px solid gray;
            padding:  10px 8px;
        }
        ul{
            border: 1px solid yellow;
            display: none;
        }
        li{
            font-size: 13px;
            padding: 5px 10px;
            list-style: none;
        }
        li:hover{
            background: #eee;
        }
    </style>
</head>
<body>
    <div>
        <input type="text" placeholder="小米笔记本">
        <ul>
            <li>全部商品</li>
            <li>小米11</li>
            <li>小米10S</li>
            <li>小米笔记本</li>
            <li>小米手机</li>
            <li>黑鲨4</li>
            <li>空调</li>
        </ul>
    </div>


    <script>

    const ipt = document.querySelector('input')
    const ul = document.querySelector('ul')
    const li = document.querySelector('li')
    ipt.addEventListener('focus',function(){
        ul.style.display = 'block'
        
    })
    ipt.addEventListener('blur',function(){
        ul.style.display = 'none'
    })

    </script>
</body>
</html>